package
{
	import mx.containers.ViewStack;
	import mx.core.Application;
	
	import p2p.controller.events.LoginEvent;
	import p2p.model.vo.LoginVO;
	import p2p.view.components.LoginPage;
	import p2p.view.components.MainBox;
	
	public class P2PBase extends Application
	{	
		[Bindable]
		public var loginPage:LoginPage;
		[Bindable]
		public var mainBox:MainBox;
		[Bindable]
		public var vs:ViewStack;
		
		public function P2PBase()
		{
			super();
			addEventListener(LoginEvent.LOGIN_EVENT, onLoginEvent);
		}	
		
		private function onLoginEvent(e:LoginEvent) : void
		{
			var vo:LoginVO = e.loginData;
			if (vo.logIn)
			{
				vs.selectedChild = mainBox;
				mainBox.connect(vo.userName, vo.userGroup);
			}
			else
			{
				vs.selectedChild = loginPage;
			}
		}
	}
}